/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.google.code.motoo.core;

import java.net.SocketAddress;
import java.nio.channels.SocketChannel;

import com.google.code.motoo.filter.FilterChain;

/**
 * 
 * @author linfengqi
 * @version 1.0  May 13, 2009
 */
public interface IoSession {
	String IO_FILTER_CHAIN = "io_filter_chain";
	String PROTOCOL_ENCODER_OUTPUT = "protocol_encoder_output";
	String TASK_EXECUTOR = "task_executor"; 
	String WRITE_EXECUTOR = "write_executor"; 
	String KEEP_ALIVE = "keep_alive"; 
	
	IoHandler getHandler();
	
	FilterChain getFilterChain();
	
	void write(Object message);
	
	void close(boolean immediately);
	
	void close();
	
    boolean isConnected();

    boolean isClosing();
    
    long getCreationTime();
    
    void setLastAccessTime();
    
    long getLastAccessTime();
    
    boolean timeout(long currentTime, long maxIdleTime);
    
    IoBuffer getIoBuffer();
    
    SocketAddress getRemoteAddress();

    SocketAddress getLocalAddress();
    
    SocketChannel getSocketChannel();
    
    Object getAttribute(Object key);

    Object setAttribute(Object key, Object value);
    
    boolean containsAttribute(Object key);
	
}
